; *** Halma
; *** Copyright 1998-2002 Zillions Development
; v.2.0

; You need to purchase Zillions of Games to load this rules file
; Visit the Zillions web site at http://www.zillions-of-games.com

(version "2.0")
(translate
 ("White" "白方") ("Black" "黑方") ("counter" "棋子")
 ("8x8 Halma (Grasshopper)" "方格跳棋 8x8")
 ("16x16 Halma" "方格跳棋 16x16")
)

(define step ($1 (verify empty?) add))

(define jump (
     (verify (not last-from?))
     $1
     (verify not-empty?)
     $1
     (verify empty?)
     to
     (if last-from? back (verify (not last-to?))) ; Can't retrace step
     (add-partial jumptype)
))
(define outjump ( ; jump from home zone over enemy counter
     (verify (in-zone? home))
     (verify (not last-from?))
     $1
     (verify enemy?)
     $1
     (verify empty?)
     to
     (if last-from? back (verify (not last-to?))) ; Can't retrace step
     (add-partial jumptype)
))


; ***** 8x8 Halma (Grasshopper) *****

(define black-yard-8 a8 b8 c8 d8 a7 b7 c7 a6 b6 a5)
(define white-yard-8 e1 f1 g1 h1 f2 g2 h2 g3 h3 h4)

(variant
  (title "8x8 Halma (Grasshopper)")
  (history "16x16 Halma was invented in 1883 by a 30-year-old Havard Medical School
	   graduate, George Howard Monks, who was then studying in London and 
	   subsequently went on to become a prominent British surgeon.  Halma caught
	   on in England and even became the favorite game of the last Empress of
	   Russia, Alexandra Feodorovna.  Halma isn't played very much
	   in the U.S., despite a 1938 release here by Parker Brothers.  The word
	   `Halma` comes from the Greek word for `leap`.
	   \\`Grasshopper` is a French version of Halma, which can be played with a
	   standard Checkers board and set.")
  (option "prevent flipping" 2)
  (board
        (image "images\Halma\hbrd8x8.bmp")
        (grid
            (start-rectangle 1 1 18 18); top-left position
            (dimensions ;16x16
                ("a/b/c/d/e/f/g/h" (19 0)) ; columns
                ("8/7/6/5/4/3/2/1" (0 19)) ; rows
			)
			(directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			     (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
			)
		)
		(symmetry White (n s)(e w)(w e)(s n)(ne sw)
		                (sw ne) (nw se) (se nw))
		(zone
          (name home)
          (players White)
          (positions (white-yard-8))
        )
	    (zone
          (name home)
          (players Black)
          (positions (black-yard-8))
        )
	)
	(board-setup
        (White (counter off 1 (white-yard-8)))
		(Black (counter off 1 (black-yard-8)))
	)
	(win-condition (White)
	   (absolute-config counter ( (black-yard-8) ))
	)
	(win-condition (Black)
	   (absolute-config counter ( (white-yard-8) ))
    )
	(loss-condition (White Black) repetition) ; Prevents infinite moves
)


; ***** 16x16 Halma *****

(define black-yard-16
	a16 a15 a14 a13 a12
	b16 b15 b14 b13 b12
	c16 c15 c14 c13
	d16 d15 d14
	e16 e15
)
(define white-yard-16
			 l2 l1
		  m3 m2 m1
	   n4 n3 n2 n1
	o5 o4 o3 o2 o1
	p5 p4 p3 p2 p1
)

(game
    (title "16x16 Halma")
	(description "将自己棋子全部走入对方区域者胜。
		每回合移动一个棋子。\\可以：\\
		1) 八方向移动1格。\
		2) 八方向跳过一个棋子至后面的空格。可以连跳。\\本规则中，在初始位置的棋子若可以跳过对方棋子，则必须跳过，不能走其他步。")
	(strategy "Since a counter which has just jumped can continue jumping, you should
	   try to form long `ladders` of jumpable counters to
	   more quickly get your counters down the board.")
	(history "16x16 Halma was invented in 1883 by a 30-year-old Havard Medical School
	   graduate, George Howard Monks, who was then studying in London and 
	   subsequently went on to become a prominent British surgeon.  Halma caught
	   on in England and it is still enjoyed there, but is not played very much
	   in the U.S., despite a 1938 release here by Parker Brothers.  The word
	   `Halma` comes from the Greek word for `leap`.   The board game version can
         also be played by four players (individually or in partnership), each
         starting in a different corner.")
    (option "pass partial" true)
	(click-sound "Audio\\Metal1.wav")
	(release-sound "Audio\\Metal2.wav")
    (move-sound "Audio\\Metal2.wav")
    (players White Black)
    (turn-order White Black)
	(move-priorities outmove)
    (board
        (image "images\Halma\halmabrd.bmp")
        (grid
            (start-rectangle 1 1 18 18); top-left position
            (dimensions ;16x16
                ("a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p" (19 0)) ; columns
                ("16/15/14/13/12/11/10/9/8/7/6/5/4/3/2/1" (0 19)) ; rows
			)
			(directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			     (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
			)
		)
		(symmetry White (n s)(e w)(w e)(s n)(ne sw)
		                (sw ne) (nw se) (se nw))
		(zone
          (name home)
          (players White)
          (positions (white-yard-16))
        )
	    (zone
          (name home)
          (players Black)
          (positions (black-yard-16))
        )
	)
    (piece
        (image White "images\Halma\wball.bmp"
			   Black "images\Halma\bball.bmp")
        (name counter)
		(help "棋子可以八方向走一格，或像跳棋一样。")
		(description "1) 八方向移动1格。\
		2) 八方向跳过一个棋子至后面的空格。可以连跳。\\请点击工具栏的“跳过”按钮终止移动。")
		(moves
		    (move-type outmove)
			(outjump s)
			(outjump e)
			(outjump se)
			(move-type jumptype)
			(jump n)
			(jump e)
			(jump s)
			(jump w)
			(jump ne)
			(jump nw)
			(jump se)
			(jump sw)
			(move-type nonjumptype)
			(step n)
			(step e)
			(step s)
			(step w)
			(step ne)
			(step nw)
			(step se)
			(step sw)	
		)			
	)

    
    (board-setup
        (White (counter off 1 (white-yard-16)))
        (Black (counter off 1 (black-yard-16)))
	)
    (win-condition (White)
		(absolute-config counter ( (black-yard-16) ))
	)
	(win-condition (Black)
		(absolute-config counter ( (white-yard-16) ))
	)
	(loss-condition (White Black) repetition) ; Prevents infinite moves
)
